<script>
	import webUni from "@/common/uni.webview.1.5.2.js";
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')

			window.Back = function(data) {
				// 获取当前页面栈
				const pages = getCurrentPages();
				// 获取页面层级数量
				const pageLevelCount = pages.length;
				// uni.$u.toast(pages[pageLevelCount - 1].route)
				// uni.$u.toast(JSON.stringify(pages))
				if (pages[pageLevelCount - 1].route == "page/reCharge/success") {
					uni.reLaunch({
						url: "/pages/index/index"
					})
					return
				}
				if (pages[pageLevelCount - 1].route == "page/withdrawal/success") {
					uni.reLaunch({
						url: "/pages/index/index"
					})
					return
				}
				// return
				console.log('当前页面层级数量为:', pageLevelCount);
				if (pageLevelCount == 1) {
					// uni.$u.toast("最后一层,退出h5");
					// setTimeout(() => {
					webUni.postMessage({
						data: {
							type: "back",
							data: []
						},
					})
					uni.removeStorageSync("Info")
					uni.removeStorageSync("urlParams")
					uni.removeStorageSync("wxUserInfo")
					// }, 1500)
					// return
				} else {
					// uni.$u.toast("触发返回");
					// setTimeout(() => {
					uni.navigateBack({
						delta: 1
					})
					// }, 1500)
				}

			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	/*每个页面公共css */
</style>